package com.dtf.core.common.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 对于任何请求的地址，先判断是否有对应的jsp存在，如果存在，就直接转向到对应的jsp文件
 * 
 * @author Administrator
 * 
 */

/**
 * 禁止jsp直接方问 把*.jsp直接映射成*.shtml
 */
//@Controller
//@RequestMapping("/**/*.shtml")
public class ForwardJspController {

	@RequestMapping
	public String forwardJsp(ModelMap model, HttpServletRequest request,
			HttpServletResponse response) {

		String t_url = request.getRequestURI().toString();
		try {

			//自动截取掉第一段，如果从根目录访问，注释掉
//			t_url = t_url.substring(t_url.indexOf("/", 1) + 1, t_url.length());

			t_url = t_url.replaceAll(".shtml", "");
//			System.out.println("call forwardJsp method,t_url=" + t_url);
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		return t_url;
	}
}
